/*  ----------------------------------------------------------------------------
 *  Arello Mobile
 *  Fast 3d Engine
 *  ----------------------------------------------------------------------------
 * Except where otherwise noted, this work is licensed under
 * http://creativecommons.org/licenses/by/3.0
 */

#ifndef __LIB2D_GUI_BUTTON_H__
#define __LIB2D_GUI_BUTTON_H__

#include "Object.h"
#include "view/Button.h"
#include <xml/Object.h>

namespace liba
{
namespace lib2d
{
namespace gui
{

class Button:
	public Object,
	public xml::ObjectANSI
{
protected:
	AutoPtr< view::Button > view;

	bool mouse_over;
public:
	explicit Button( Object * parent, const Rect & rect = Rect( 0, 0, 0, 0 ) );
	virtual ~Button();

	virtual view::Button * get_view()const
	{
		return view;
	}

	virtual bool on_attribute( xml::Provider * prov, const std::string & name, const std::string & value );
	virtual bool on_node( xml::Provider * prov, const std::string & name );

	virtual void on_button_down( const Vector2 & point, const Atom & button_name );
	virtual void on_button_up( const Vector2 & point, const Atom & button_name );
	virtual void on_mouse_move( const Vector2 & point );
	virtual void on_mouse_out();

	bool is_pressed()const
	{
		return mouse_pressed && mouse_over;
	}
	bool is_mouse_over()const
	{
		return mouse_over;
	}
};

} //namespace gui
} //namespace lib2d
} //namespace liba

using namespace liba;

#endif //__LIB2D_GUI_BUTTON_H__
